package com.sk.myview;

import com.sk.water.R;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TextView;

public class HistoryTask extends LinearLayout {
	private Context context;
	private int configid;

	public HistoryTask(Context context) {
		super(context);
		LayoutInflater.from(context).inflate(R.layout.history_task, this);
		this.context = context;
	}

	public HistoryTask(Context context, AttributeSet attributeSet) {
		super(context, attributeSet);
		LayoutInflater.from(context).inflate(R.layout.history_task, this);
		this.context = context;
		
	}
	public void setConfigID(int id){
		configid = id;
	}
	public int getConfigID(){
		return configid;
	}
	public void initialize(){
		setClickable(true);
		setBackgroundResource(R.drawable.single_choice);
	}

	public void addRecord(String recordName, String recordUnit, String recordValue) {
		View recordView = LayoutInflater.from((Activity)context).inflate(R.layout.history_task_rows, null);
		TableLayout fartherLayout = (TableLayout) findViewById(R.id.history_task_record);
		TextView name = (TextView) recordView
				.findViewById(R.id.history_task_record_name);
		TextView unit = (TextView) recordView
				.findViewById(R.id.history_task_record_unit);
		TextView value = (TextView) recordView
				.findViewById(R.id.history_task_record_value);
		name.setText(recordName);
		unit.setText(recordUnit);
		value.setText(recordValue);
		fartherLayout.addView(recordView);
	}
}
